<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  function boy(girl){
    this.g = girl.name;
    this.send = function(msg){
      console.log(`${this.g}，这是我送你的${msg}`)
    }
  }

  function girl(n){
    this.name = n;
  }

  function proxy(girl){
    this.message = [];
    this.g = girl.name
    this.send = function(msg){
      const b = new boy(girl);

      // 拦截到的时机，或数据，或动作
      // console.log(msg);
      // console.log("要执行发送数据的功能了")
      // msg = "一支鲜花"
      this.message.push({
        收货人: this.g,
        发件人: b,
        时间: Date.now(),
        data: msg
      })

      b.send(msg); 
    }
  }

  const g = new girl("翠花");

  const p = new proxy(g);
  p.send("一束鲜花");
  p.send("一碗麻辣烫");
  p.send("一本书");

  // const b = new boy(g);
  // b.send("一束鲜花");
  
</script>
</html>